/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package AjouConquerorBeans;

import data.customLocation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import javax.ejb.Singleton;

/**
 *
 * @author ajou
 */
@Singleton
public class Nowuser {
    
    private Map<Integer, ArrayList<customLocation>> users = new HashMap<Integer, ArrayList<customLocation>>();
    
    public ArrayList<customLocation> getUsers(int num) {
        return users.get(num);
    }
    
    public int getRoomById(String id) {        
        for(int key : users.keySet()) {
            for (customLocation u : users.get(key)) {
                System.out.println("id is " + u.getId());
                if (u.getId() != null && u.getId().equals(id))
                    return key;
            }
        }
        
        return -1;
    }
    
    public void setRoom(int num, ArrayList<customLocation> user) {
        users.put(num, user);
    }
    
    public void setLocation(int num, customLocation user) {
        for (customLocation u : users.get(num)) {
            if (u.getId() != null && user.getId() != null && u.getId().equals(user.getId())) {
                u.setLatitude(user.getLatitude());
                u.setLongitude(user.getLongitude());
            }
        }
    }

}
